<{include file="header.html"}>
<script src="js/jquery-1.5.2.min.js"  language="javascript" ></script>
<script src="lib/uploadify/swfobject.js"  language="javascript" ></script>
<script src="lib/uploadify/jquery.uploadify.v2.1.4.min.js"  language="javascript" ></script>
<link href="lib/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<style>
<!--
input{width:500px;}
#uploadpanel 
{
	border:solid 1px #cccccc;
}
#uploadpanel input[type=radio]
{
	width:15px;
	height:15px;
	
}
#uploadpanel div
{
	padding:5px;
}

#upload_browser_ftp input[type=checkbox]
{
	width:15px;
	height:15px;
}
-->
</style>
<script language="javascript">
$(function(){
	$("#uploadifyupload").uploadify({
		'uploader': 'lib/uploadify/uploadify.swf',
		'cancelImg': 'lib/uploadify/cancel.png',
		'script': 'upload_gateway.php',
		'folder': 'files',
		'buttonText':'Choose',
		'multi': false,
		'fileExt':'*.mp4;',
		'fileDesc':'Video Files',
		'auto': true,
		'queueSizeLimit':1,
		'scriptData':{'<{$session_name}>':'<{$session_id}>','action':'uploadTMPFile'},
		'displayData': 'speed',
		'onComplete':function(event,queueID,fileObj,response,data){
			try
			{
				var responseObj = eval("("+response+")");
			}catch(ex)
			{
				alert("上传失败");
				return false;
			}
			
			if(!responseObj)
			{
				alert(response);
			}else{
				if(responseObj.error && responseObj.error.length > 0)
				{
					alert(responseObj.error);
				}else{
					fileName = responseObj.data.tmpname;
					$('#ajaxf_video_value').val(fileName);	
				}
			}
		},
		'onError':function(event,queueId,fileObj,errorObj){
			alert(errorObj);
		},
		'onUploadError' : function(file, errorCode, errorMsg, errorString) {
            alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
        },
        'onUploadStart' : function(file) {
            alert('Starting to upload ' + file.name);
        },
        'onDialogOpen' : function() {
            $('#message_box').html('The file dialog box was opened...');
        } 
	});
});

function submitForm(form)
{
	/*
	if(form['name'].value == '')
	{
		alert("請填入名稱");
		form['name'].focus();
		return false;
	}
	*/
	/*
	if(form['ajaxf_images_value'].value == '')
	{
		alert("請選擇圖档");
		return false;
	}
	*/
	return true;
}
$(function(){
	$('#uploadpanel input[type=radio]').click(function(){

		$('#upload_browser_panel').hide();
		$('#upload_browser_ftp').hide();
		
		$("#"+$(this).val()).show();
	});
});

$(function(){
	$('#upload_browser_ftp input[type=checkbox]').click(function(){
		var ui_obj_status = $(this).attr('checked');
		$('#upload_browser_ftp input[type=checkbox]').attr('checked',false);
		$(this).attr('checked',ui_obj_status);
	});
});
</script>
<div class="formpanel">
<form action="<{spUrl c=$controller a=edit}>" method="post" enctype="multipart/form-data" name="form1" style="width:600px;" onsubmit="return submitForm(this);">

	<input type="hidden" name="uuid" value="<{$data['uuid']}>"/>
	<label>英文名称：</label>
	<input name="name_en" value="<{$data['name_en']}>"/>
	<label>中午名称：</label>
	<input name="name_cn" value="<{$data['name_cn']}>"/>
	
	<label>排序：</label>
	<input name="sort" value="<{$data['order']}>"/>
	<label>是否显示：</label>
	<select name="active">
			<option value="Y">显示</option>
			<option value="N" <{if $data['active'] != 'Y'}>selected="selected"<{/if}>>不显示</option>
		</select>
	

	<label>视频：</label>
	<div id="uploadpanel">
		<div><input type="radio" checked="checked" name="filesource" value="upload_browser_panel">浏览器上传&nbsp;&nbsp;<input type="radio" name="filesource" value="upload_browser_ftp">FTP选取</div>
		<hr>
		<div id="upload_browser_panel">
			<span>视频大小不能够超过100M</span>
			<BR>
			<input id="uploadifyupload"  type="file" />
			<input type="hidden" id="ajaxf_video_value" name="ajaxf_video_value" value=""/>
		</div>
		<div id="upload_browser_ftp" style="display:none;">
			<span>请讲视频文件上传到网站ftp文件夹，格式为mp4。 文件名请不要包含中文和特殊字符，下划线英文字符组成</span>
			<br>
			<table cellspacing="8" width="100%">
			<tr>
				<th align="left">文件名</th>
				<th align="left" width="100">大小</th>
				<th align="left" width="50">选取</th>
			<tr>
			<{foreach item=ftp_file_info from=$fpt_file_list}>
			<tr>
			<td><{$ftp_file_info.name}></td>
			<td><{$ftp_file_info.size}></td>
			<td><input type="checkbox" value="<{$ftp_file_info.name}>" name="ftp_file_name"/></td>
			<tr>
			<{/foreach}>
			</table>
			
	
		</div>
	</div>	

	<label></label>
	<{if $data['uuid']}>
	<input type="submit" value="更新"/>
	<{else}>
	<input type="submit" value="新增"/>
	<{/if}>
	
	&nbsp;&nbsp;
	<input type="button" class="submit" value="返回列表" onclick="document.location='<{spUrl c=$controller a=index}>';return false;"/>

</form>
</div>
<{include file="footer.html"}>